package box.mantianx.dao.lmpl;

import box.mantianx.dao.UserMapper;
import box.mantianx.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author starrysky
 * @title: UserMapperImpl
 * @projectName spring_ma
 * @description: TODO
 * @date 2021/2/315:31
 */
public class UserMapperImpl implements UserMapper {

    private SqlSessionTemplate sqlSessionTemplate;

    public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }

    @Override
    public CopyOnWriteArrayList<User> getUser() {
        UserMapper mapper = sqlSessionTemplate.getMapper(UserMapper.class);
        CopyOnWriteArrayList<User> user = mapper.getUser();
        return user;
    }

    @Override
    public int insertUser(Long id, String name, String pwd) {
        UserMapper mapper = sqlSessionTemplate.getMapper(UserMapper.class);
        int status = mapper.insertUser(id, name, pwd);
        return status;
    }


}
